package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyLifeType;
import com.laowang.project.system.service.MyLifeTypeService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 生活朋友圈分类Controller
 *
 * @author laowang
 * @date 2023-04-24
 */
@Api(tags = "生活朋友圈分类接口")
@RestController
@RequestMapping("/lifeType")
public class MyLifeTypeController extends BaseController {
    @Autowired
    private MyLifeTypeService myLifeTypeService;

    @ApiOperation(value = "小程序端 获取生活朋友圈分类",notes = "")
    @GetMapping("/web/list")
    public AjaxResult list( ) {

        List<MyLifeType> list = myLifeTypeService.selectMyLifeTypeList(null);
        return AjaxResult.success("操作成功",list);
    }

    /**
     * 查询生活朋友圈分类列表
     */
    @ApiOperation(value = "查询生活朋友圈分类列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:lifeType:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyLifeType myLifeType) {
        startPage();
        List<MyLifeType> list = myLifeTypeService.selectMyLifeTypeList(myLifeType);
        return getDataTable(list);
    }

    /**
     * 导出生活朋友圈分类列表
     */
    @ApiOperation(value = "导出生活朋友圈分类列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:lifeType:export')")
    @Log(title = "生活朋友圈分类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyLifeType myLifeType) {
        List<MyLifeType> list = myLifeTypeService.selectMyLifeTypeList(myLifeType);
        ExcelUtil<MyLifeType> util = new ExcelUtil<MyLifeType>(MyLifeType.class);
        return util.exportExcel(list, "type");
    }

    /**
     * 获取生活朋友圈分类详细信息
     */
    @ApiOperation(value = "获取生活朋友圈分类详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:lifeType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myLifeTypeService.selectMyLifeTypeById(id));
    }

    /**
     * 新增生活朋友圈分类
     */
    @ApiOperation(value = "新增生活朋友圈分类",notes = "")
    @PreAuthorize("@ss.hasPermi('my:lifeType:add')")
    @Log(title = "生活朋友圈分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyLifeType myLifeType) {
        return toAjax(myLifeTypeService.insertMyLifeType(myLifeType));
    }

    /**
     * 修改生活朋友圈分类
     */
    @ApiOperation(value = "修改生活朋友圈分类",notes = "")
    @PreAuthorize("@ss.hasPermi('my:lifeType:edit')")
    @Log(title = "生活朋友圈分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyLifeType myLifeType) {
        return toAjax(myLifeTypeService.updateMyLifeType(myLifeType));
    }

    /**
     * 删除生活朋友圈分类
     */
    @ApiOperation(value = "删除生活朋友圈分类",notes = "")
    @PreAuthorize("@ss.hasPermi('my:lifeType:remove')")
    @Log(title = "生活朋友圈分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myLifeTypeService.deleteMyLifeTypeByIds(ids));
    }
}
